//
//  UIView+Extension.swift
//  XJWeiBo
//
//  Created by 李旭杰 on 2017/3/26.
//  Copyright © 2017年 李旭杰. All rights reserved.
//

import UIKit

/// 给 UIView 添加计算属性

extension UIView {
    /// x 坐标
    var x: CGFloat {
        get{
            return frame.origin.x
        }set{
            frame.origin.x = newValue
        }
    }
    
    /// y 坐标
    var y: CGFloat {
        get{
            return frame.origin.y
        }set{
            frame.origin.y = newValue
        }
    }
    
    /// centerX 坐标
    var centerX: CGFloat {
        get{
            return center.x
        }set{
            center.x = newValue
        }
    }
    
    /// centerY 坐标
    var centerY: CGFloat {
        get{
            return center.y
        }set{
            center.y = newValue
        }
    }
    
    /// width 宽
    var width: CGFloat {
        get{
            return bounds.size.width
        }set{
            bounds.size.width = newValue
        }
    }
    
    /// height  高
    var height: CGFloat {
        get{
            return bounds.size.height
        }set{
            bounds.size.height = newValue
        }
    }
    
    /// size  尺寸
    var size: CGSize {
        get{
            return frame.size
        }set{
            frame.size = newValue
        }
    }
    
}
